package sdfi.lee.test;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.sql.Connection;

import sdfi.lee.DAO.DAO;
import sdfi.lee.Properties.ReadXMLFromString;

public class file {

	/**
	 * @param args
	 */
	public static void listFile(String path)
	{
		File file=new File(path);
//		System.out.println(path);
		if(!file.exists()) return ;
		if(file.isDirectory())
		{
			for(File f:file.listFiles())
			{
				listFile(f.getAbsolutePath());
			}
		}
		else
		{
			chile(path);
		}
	}
	public static void chile(String path)
	{
		//System.out.println(path);
		
		try
		{
		FileInputStream fis=new FileInputStream(new File(path));
		InputStreamReader isr=new InputStreamReader(fis);
		BufferedReader br=new BufferedReader(isr);
		String line=br.readLine();
		StringBuffer sb=new StringBuffer();
		while(line!=null)
		{
			sb.append(line);
			line=br.readLine();
		}
		Connection con=DAO.openSession().connection();
		
		con.setAutoCommit(false);
		String sql="insert into rollnotice(rolltitle,rollpath,rolldate,rolltype)values(";
		con.createStatement().executeUpdate(sql);
		con.commit();
		System.out.println(path);
		
			}
		catch(Exception ee)
		{
			
			ee.printStackTrace();
			
		}
//		*/
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
//		for(int i=9;i<14;i++)
//		{
//			listFile("V:/person/"+i);
//		}
//		System.out.print("\n"+"sadf"+"\n");
		listFile("V:/product/");
	}

}
